package unit5.collection;

import java.util.LinkedList;

public class LinkedList_Stack {
    //成员属性
    LinkedList ll=new LinkedList();
    //构造方法

    public LinkedList_Stack(){
    }
    //成员方法
    //      进栈
    void push(Object o){
        ll.add(o);
    }
    //出栈
    Object pop(){
        return ll.removeLast();
    }
    //获取栈顶元素
    Object peek(){
        return ll.getLast();
    }

    public static void main(String[] args) {
        LinkedList_Stack lls=new LinkedList_Stack();
        lls.push("王小二");
        lls.push("李四");
        lls.push("张山");
        lls.push("王五");
        System.out.println(lls.peek());
        System.out.println(lls.pop());
        System.out.println(lls.peek());
        lls.push("黄六");
        System.out.println(lls.peek());
        System.out.println(lls.pop());
        System.out.println(lls.peek());
    }
}
